<div id="divImport">
    <ul>
        <li><a href="#divImportProduct">New Product</a></li>
        <li><a href="#divImportCust">New Customer Information</a></li>
        <li><a href="#divImportCustPrice">Edit Customer Information</a></li>
    </ul>
    <div id="divImportProduct">
        <h1>Template for new ITS Product.</h1>
        <?php echo $form->create('Product', array('type' => 'file', 'url' => array('action' => 'import'))); ?>
        <table>
            <tbody>
                <tr>
                    <td width="30px"><?php echo $form->label('Product.file', 'File'); ?></td>
                    <td><?php echo $form->file('Product.file', array('size' => 50)); ?></td>
                </tr>
                <tr>
                    <td align="center">&nbsp;</td>
                    <td class="right">
                        <?php echo $html->link('Download Template', array('controller' => 'products', 'action' => 'template'), array('class' => 'btnTemplate ui-state-default ui-corner-all template', 'style' => 'padding: 4px 5px; margin-top: 5px') ); ?>
                        <button class="btnSubmit ui-state-default ui-corner-all" type="button" onclick="this.form.submit()" style="padding: 2px; margin-top: 5px">
                            <?php echo $html->image('icon/import.png'); ?>
                            Import
                        </button>
                    </td>
                </tr>
            </tbody>
        </table>
        <?php echo $form->end(); ?>
    </div>
    <div id="divImportCust">
        <h1>Template for new Customer Product.</h1>
        <fieldset>
            <legend>Template</legend>
            <?php echo $form->create('Customer', array('type' => 'file', 'url' => array('controller' => 'products', 'action' => 'template_cust'))); ?>
            <table>
                <tbody>
                    <tr>
                        <td width="110px"><?php echo $form->label('Product.customer_id', 'Customer', array('class' => 'required')); ?></td>
                        <td><?php echo $form->select('Product.customer_id', $customers); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo $form->label('Product.site_id', 'Site', array('class' => 'required')); ?></td>
                        <td><?php echo $form->select('Product.site_id'); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo $form->label('Product.supplier_id', 'Vendor', array('class' => 'required')); ?></td>
                        <td><?php echo $form->select('Product.supplier_id', $suppliers); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo $form->label('Product.brand_id', 'Brand'); ?></td>
                        <td><?php echo $form->select('Product.brand_id'); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo $form->label('Product.dispatch_from', 'Dispatch From'); ?></td>
                        <td><?php echo $form->radio('Product.dispatch_from', array('its' => 'ITS', 'supplier' => 'Other Vendor'), array('separator' => '&nbsp;', 'legend' => false)); ?></td>
                    </tr>
                </tbody>
            </table>
            <fieldset>
                <legend>Part no. Criteria</legend>
                <table>
                    <tr>
                        <td width="140px"><?php echo $form->label('limit', 'Number of Products'); ?></td>
                        <td>
                            <?php echo $form->text('Product.limit', array('size' => 5)); ?> entries
                        </td>
                    </tr>
                    <tr>
                        <td align="center">&nbsp;</td>
                        <td class="right">
                            <button class="btnTemplate ui-state-default ui-corner-all" type="button" style="padding: 2px; margin-top: 5px" >
                                <?php echo $html->image('icon/template.png'); ?> Download Template
                            </button>
                        </td>
                    </tr>
                </table>
            </fieldset>
        </fieldset>
        <?php echo $form->end(); ?>
        <fieldset>
            <legend>Import</legend>
            <?php echo $form->create('Customer', array('type' => 'file', 'url' => array('controller' => 'products', 'action' => 'import_cust'))); ?>
            <table>
                <tbody>
                    <tr>
                        <td width="30px"><?php echo $form->label('Product.file', 'File'); ?></td>
                        <td><?php echo $form->file('Product.file', array('size' => 50)); ?></td>
                    </tr>
                    <tr>
                        <td align="center">&nbsp;</td>
                        <td class="right">
                            <button class="btnSubmit ui-state-default ui-corner-all" type="button" onclick="this.form.submit()" style="padding: 2px; margin-top: 5px">
                                <?php echo $html->image('icon/import.png'); ?>
                                Import
                            </button>
                        </td>
                    </tr>
                </tbody>
            </table>
            <?php echo $form->end(); ?>
        </fieldset>
    </div>
    <div id="divImportCustPrice">
        <h1>Template for Customer Information Editing.</h1>
        <fieldset>
            <legend>Template</legend>
            <?php echo $form->create('Customer', array('type' => 'file', 'url' => array('controller' => 'products', 'action' => 'template_cust_price'))); ?>
            <table>
                <tbody>
                    <tr>
                        <td width="110px"><?php echo $form->label('Product.customer_id', 'Customer', array('class' => 'required', 'for' => 'ProductCustomerId2')); ?></td>
                        <td><?php echo $form->select('Product.customer_id', $customers, null, array('id' => 'ProductCustomerId2')); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo $form->label('Product.site_id', 'Site', array('class' => 'required', 'for' => 'ProductSiteId2')); ?></td>
                        <td><?php echo $form->select('Product.site_id', null, null, array('id' => 'ProductSiteId2')); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo $form->label('Product.supplier_id', 'Vendor', array('class' => 'required', 'for' => 'ProductSupplierId2')); ?></td>
                        <td><?php echo $form->select('Product.supplier_id', $suppliers, null, array('id' => 'ProductSupplierId2')); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo $form->label('Product.brand_id', 'Brand', array('for' => 'ProductBrandId2')); ?></td>
                        <td><?php echo $form->select('Product.brand_id', null, null, array('id' => 'ProductBrandId2')); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo $form->label('Product.dispatch_from', 'Dispatch From', array('for' => 'ProductDispatchFrom2')); ?></td>
                        <td><?php echo $form->radio('Product.dispatch_from', array('its' => 'ITS', 'supplier' => 'Other Vendor'), array('separator' => '&nbsp;', 'legend' => false, 'id' => 'ProductDispatchForm2')); ?></td>
                    </tr>
                    <tr>
                        <td align="center">&nbsp;</td>
                        <td class="right">
                            <button class="btnTemplate ui-state-default ui-corner-all" type="button" style="padding: 2px; margin-top: 5px" >
                                <?php echo $html->image('icon/template.png'); ?> Download Template
                            </button>
                        </td>
                    </tr>
                </tbody>
            </table>
        </fieldset>
        <?php echo $form->end(); ?>
        <fieldset>
            <legend>Import</legend>
            <?php echo $form->create('Customer', array('type' => 'file', 'url' => array('controller' => 'products', 'action' => 'import_cust_price'))); ?>
            <table>
                <tbody>
                    <tr>
                        <td width="30px"><?php echo $form->label('Product.file', 'File', array('for' => 'ProductFile2')); ?></td>
                        <td><?php echo $form->file('Product.file', array('size' => 50, 'id' => 'ProductFile2')); ?></td>
                    </tr>
                    <tr>
                        <td align="center">&nbsp;</td>
                        <td class="right">
                            <button class="btnSubmit ui-state-default ui-corner-all" type="button" onclick="this.form.submit()" style="padding: 2px; margin-top: 5px">
                                <?php echo $html->image('icon/import.png'); ?>
                                Import
                            </button>
                        </td>
                    </tr>
                </tbody>
            </table>
            <?php echo $form->end(); ?>
        </fieldset>
    </div>
</div>
<script type="text/javascript">
    $j(function() {
        $j("#divImport").tabs(tab_options);
        $j(".btnSubmit").handover().click(function() {
            $j('#popup').dialog('close');
        });

        $j('#ProductDispatchFromIts').attr('checked', 'checked');

        $j(".btnTemplate").handover();
        $j("#divImportCust .btnTemplate").click(function() {
            if ($j.areEmpty('ProductCustomerId', 'ProductSiteId', 'ProductSupplierId')) {
                return false;
            } else {
                $j(this).parents('form').submit();
            }
        });
        $j("#divImportCustPrice .btnTemplate").click(function() {
            if ($j.areEmpty('ProductCustomerId2', 'ProductSiteId2', 'ProductSupplierId2')) {
                return false;
            } else {
                $j(this).parents('form').submit();
            }
        });

        $j("#ProductCustomerId").bind('change', function() {
            $j('#ProductSiteId').requestOptions("sites/option_list", $j(this).val());
        });

        $j("#ProductSupplierId").bind('change', function() {
            $j('#ProductBrandId').requestOptions("brands/option_list", $j(this).val());
        });

        $j("#ProductCustomerId2").bind('change', function() {
            $j('#ProductSiteId2').requestOptions("sites/option_list", $j(this).val());
        });

        $j("#ProductSupplierId2").bind('change', function() {
            $j('#ProductBrandId2').requestOptions("brands/option_list", $j(this).val());
        });

    });
</script>